<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<title>Test that TabBar is at the bottom of the viewport on each view</title>

	<script type="text/javascript" src="../../../deviceTheme.js"></script>
	<script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script>

	<script type="text/javascript" src="../TestUtil.js"></script>
	<script type="text/javascript">
		require([
				 "doh/runner",	//doh functions
				 "dojo/ready",
                 "dojo/dom",
                 "dojo/dom-class",
                 "dojo/dom-style",
                 "dojo/window",
                 "dojo/_base/window",
                 "dojox/mobile/sniff",
		         "dojox/mobile/parser",
		         "dojox/mobile",
		         "dojox/mobile/compat",
		         "dojox/mobile/ScrollableView",
		         "dojox/mobile/TabBar"
		     ], function(runner, ready, dom, domClass, domStyle, win, winUtils, has){
				ready(function(){
					var tabBar = dom.byId("thetabbar");
					var tabHome1 = dom.byId("tabHome1");
					var tabHome2 = dom.byId("tabHome2");
					var statusBar = dom.byId("statusbar");
					var tabEvents = dom.byId("tabEvents");
					// there is 8px of extra padding -in the body) with the WindowsPhone theme
					var extraPadding = 0;
					if (domClass.contains(winUtils.doc.documentElement, "windows_theme")){
						extraPadding = 8;
					}
					doh.register("dojox.mobile.test.doh.fixedbars.DeclaredFixedFooterTests", [
   						{
 							name: "ticket #17006: verify tabbar is correct on view Home1",
 							timeout: 10000,
 							runTest: function(){
 								var d = new runner.Deferred();
 								setTimeout(d.getTestCallback(function(){
 									var viewport = win.getBox();
 									runner.assertEqual(tabHome1.offsetHeight, tabBar.offsetTop, "tabbar should be right below tabHome1");
 									runner.assertEqual(viewport.h, tabBar.offsetTop + tabBar.offsetHeight + extraPadding, "tabbar should be at the bottom of the viewport when tabHome1 is displayed");
 								}), 1000);
 								return d;
 							}
 						},{
 							name: "ticket #17006: verify tabbar is correct on view Home2",
 							timeout: 10000,
 							runTest: function(){
 								var d = new runner.Deferred();
								fireOnMouseDown("mvToHome2");
								fireOnMouseUp("mvToHome2");
 								setTimeout(d.getTestCallback(function(){
 									var viewport = win.getBox();
 									runner.assertEqual(tabHome2.offsetHeight, tabBar.offsetTop, "tabbar should be right below tabHome2");
 									runner.assertEqual(viewport.h, tabBar.offsetTop + tabBar.offsetHeight + extraPadding, "tabbar should be at the bottom of the viewport when tabHome2 is displayed");
 									runner.assertEqual(tabHome2.offsetHeight, statusBar.offsetTop + statusBar.offsetHeight, "statusbar should be at the bottom of tabHome2");
 								}), 1000);
 								return d;
 							}
 						},{
 							name: "ticket #17006: verify tabbar is correct on view Events",
 							timeout: 10000,
 							runTest: function(){
 								var d = new runner.Deferred();
								fireOnMouseDown("mvToTabEvents");
								fireOnMouseUp("mvToTabEvents");
 								setTimeout(d.getTestCallback(function(){
 									var viewport = win.getBox();
 									runner.assertEqual(tabEvents.offsetHeight, tabBar.offsetTop, "tabbar should be right below tabEvents");
 									runner.assertEqual(viewport.h, tabBar.offsetTop + tabBar.offsetHeight + extraPadding, "tabbar should be at the bottom of the viewport when tabEvents is displayed");
 								}), 1000);
 								return d;
 							}
 						}]);
					runner.run();
				});
		});
	</script>

</head>
<body style="visibility:hidden;">

    <div id="tabBar" data-dojo-type="dojox.mobile.View">
    
        <div id="groups" data-dojo-type="dojox.mobile.View">    
            <div id="tabHome1" data-dojo-type="dojox.mobile.ScrollableView"
                selected="true" fixedFooter="thetabbar">
                <h1 data-dojo-type="dojox.mobile.Heading" fixed="top">Home1</h1>
                <div data-dojo-type="dojox.mobile.EdgeToEdgeList"
                    class="edgeToEdgeList">
                    <li id="mvToHome2" data-dojo-type="dojox.mobile.ListItem" moveTo="tabHome2">To Home2</li>
                </div>
            </div>
            <div id="tabHome2" data-dojo-type="dojox.mobile.ScrollableView" fixedFooter="thetabbar">
                <h1 data-dojo-type="dojox.mobile.Heading" fixed="top">Home2</h1>
                <div data-dojo-type="dojox.mobile.EdgeToEdgeList"
                    class="edgeToEdgeList">
                    <li data-dojo-type="dojox.mobile.ListItem" moveTo="tabHome1">To Home1</li>
                </div>
                <h1 id="statusbar" data-dojo-type="dojox.mobile.Heading" fixed="bottom">status bar</h1>
            </div>            
        </div>
        
        <div id="tabEvents" data-dojo-type="dojox.mobile.ScrollableView">
            <h1 data-dojo-type="dojox.mobile.Heading" fixed="top">Events</h1>
            <div data-dojo-type="dojox.mobile.RoundRect" shadow="true">Events</div>
        </div>

        <ul id="thetabbar" data-dojo-type="dojox.mobile.TabBar" fixed="bottom"
            iconBase="../../images/tab-icons.png">
            <li data-dojo-type="dojox.mobile.TabBarButton" moveTo="groups"
                iconPos1="0,0,29,29" iconPos2="29,0,29,29" selected="true">Home</li>
            <li id="mvToTabEvents" data-dojo-type="dojox.mobile.TabBarButton" moveTo="tabEvents"
                iconPos1="0,29,29,29" iconPos2="29,29,29,29">Events</li>
        </ul>
    </div>
</body>
</html>
